package com.gz.logistics.fragment;

import android.app.Activity;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.DatePicker;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gz.logistics.R;
import com.gz.logistics.adapter.OutingAssembleAdapter;
import com.gz.logistics.adapter.OutingAssembleAdapterY;
import com.gz.logistics.adapter.SpinnerAdapter;
import com.gz.logistics.app.Define;
import com.gz.logistics.app.OutingAssembleDetailActivity;
import com.gz.logistics.library.IAuthor;
import com.gz.logistics.library.IOrder;
import com.gz.logistics.library.listener.GetStoreHouseListener;
import com.gz.logistics.library.listener.GetWillOutOfStorageAssemblesListener;
import com.gz.logistics.library.listener.GetWillOutOfStorageAssemblesListenerY;
import com.gz.logistics.library.listener.RequestCode;
import com.gz.logistics.library.listener.SignAllOrdersOfTheAssembleListener;
import com.gz.logistics.library.pojo.CustomerSpinnerObject;
import com.gz.logistics.library.pojo.OrderStatusInfo;
import com.gz.logistics.library.pojo.StoreHouse;
import com.gz.logistics.library.pojo.UserInfo;
import com.gz.logistics.library.pojo.WillOutStorageAassemble;
import com.gz.logistics.library.pojo.WillOutStorageAassembleY;
import com.gz.logistics.library.util.Constants;
import com.gz.logistics.library.util.CrashHandler;
import com.gz.logistics.library.util.PreferenceModel;
import com.gz.logistics.util.ToastUtils;
import com.gz.logistics.widget.DoubleDatePickerDialog;
import com.gz.logistics.widget.FooterView;
import com.gz.logistics.widget.LoadingCover;
import com.gz.logistics.widget.SpinerPopWindow;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;


public class OutingFragment extends Fragment implements FooterView.OnFooterViewRefreshListener ,
        PullToRefreshBase.OnRefreshListener, LoadingCover.OnLoadingCoverRefreshListener,
        SpinerPopWindow.ISpinnerOnItemSelectListener, View.OnClickListener,
        DoubleDatePickerDialog.OnDateSetListener,OutingAssembleAdapter.SignALLCallbackInterface
{
    private String TAG = OutingFragment.class.getSimpleName();
    private View mConvertView;
    private UserInfo userInfo;
    private List<WillOutStorageAassemble> mDataListW;
    private List<WillOutStorageAassembleY> mDataListY;

    private TextView iv_actionbar_title;
    private TextView tv_actionbar_deliveryName;
    private RelativeLayout rl_choice_for_part;//仓库
    private RelativeLayout rl_choice_for_time;//时间
    private RelativeLayout rl_choice_for_sign;//状态选择
    private TextView tv_part_name;
    private TextView tv_time;
    private TextView tv_order;
    private PullToRefreshListView mPullListW;
    private PullToRefreshListView mPullListY;

    private LoadingCover mLoadingCover;
    private Context mContext;
    private Dialog mLoadingData;
    private FooterView mFooterView;
    private DoubleDatePickerDialog timeDialog;
    private Calendar mCalendar;

    private List<CustomerSpinnerObject> storehouse;
    private List<CustomerSpinnerObject> statusList;//订单状态列表

    private SpinnerAdapter partSpinnerAdapter;
    private SpinerPopWindow mPartSpinnerPopWindow;
    private MyStatusSpinnerItemSelectListener mStatusSpinnerListener;
    private SpinerPopWindow mStatusSpinnerPopWindow;
    private SpinnerAdapter statusSpinnerAdapter;

    private MySignAllOrdersOfTheAssembleListener  mySignAllOrdersOfTheAssembleListener;
    private OutingAssembleAdapter assembleAdapter;
    private OutingAssembleAdapterY assembleAdapterY;

    private OutingListenerW outingListenerW;

    private int page = 1;
    public static String startTime = null;
    public static String endTime = null;
    private int storehoust_id = 0;
    private int status = 2;
    private Date date ;
    private MyGetStoreHouseListener myGetStoreHousesListener;

    private MyHandler mHandler;
    private RefreshReceiver mRefreshReceiver;

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (mConvertView == null){
            mConvertView = inflater.inflate(R.layout.fragment_outing, container, false);
            init(inflater);
        }
        mRefreshReceiver = new RefreshReceiver();
        IntentFilter intentFilter = new IntentFilter(Define.PREFERENCE_OUTING);
        getActivity().registerReceiver(mRefreshReceiver, intentFilter);

        //预出库订单列表
        mDataListW = new ArrayList<WillOutStorageAassemble>();
        mDataListY = new ArrayList<WillOutStorageAassembleY>();
        assembleAdapter = new OutingAssembleAdapter(mDataListW,mContext,this);
        assembleAdapterY = new OutingAssembleAdapterY(mDataListY,mContext);
        mPullListW.setAdapter(assembleAdapter);
        mPullListY.setAdapter(assembleAdapterY);

        // 初始化"仓库选择" 控件
        storehouse = new ArrayList<CustomerSpinnerObject>();
        partSpinnerAdapter = new SpinnerAdapter(this.getActivity(),storehouse);
        mPartSpinnerPopWindow = new SpinerPopWindow(this.getActivity());
        mPartSpinnerPopWindow.setAdatper(partSpinnerAdapter);
        mPartSpinnerPopWindow.setItemListener(this);

        statusSpinnerAdapter = new SpinnerAdapter(this.getActivity(),statusList);
        mStatusSpinnerPopWindow = new SpinerPopWindow(this.getActivity());
        mStatusSpinnerPopWindow.setAdatper(statusSpinnerAdapter);
        mStatusSpinnerListener = new MyStatusSpinnerItemSelectListener(this);
        mStatusSpinnerPopWindow.setItemListener(mStatusSpinnerListener);

        mHandler = new MyHandler(this);
        mHandler.sendEmptyMessage(1);//加载仓库列表
        initListener();
        loadbuildingData();

        return mConvertView;


    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mHandler.release();
        myGetStoreHousesListener.release();
        mStatusSpinnerListener.release();
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }
    /**
     * 接收到的广播
     */
    private class RefreshReceiver extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            loadbuildingData();
        }
    }

    /**
     * 查询仓库信息未签收
     */
    private void loadbuildingData() {
        mDataListW.clear();
        mPullListY.setVisibility(View.GONE);
        mPullListW.setVisibility(View.VISIBLE);
        mPullListW.setMode(PullToRefreshBase.Mode.DISABLED);//禁止上拉下拉
        mFooterView.setVisibility(View.GONE);//隐藏底部
        status = 2;
        IOrder.getInstance().getWillOutStorageAssemblesW(storehoust_id, startTime, endTime, status, outingListenerW);
    }

    private void init(LayoutInflater mInflater) {

        mContext = getActivity().getApplicationContext();
        userInfo = IAuthor.getInstance().loadUserInfoSyn(PreferenceModel.getInt(Constants.PREFERENCE_USER_ID, -1));
        mPullListW = (PullToRefreshListView) mConvertView.findViewById(R.id.listW);
        mPullListY = (PullToRefreshListView) mConvertView.findViewById(R.id.listY);
        iv_actionbar_title = (TextView) mConvertView.findViewById(R.id.iv_actionbar_title);
        iv_actionbar_title.setText("预出库单查询");
        tv_actionbar_deliveryName = (TextView) mConvertView.findViewById(R.id.tv_actionbar_deliveryName);
        tv_actionbar_deliveryName.setText("配送员："+userInfo.getUser_name());
        rl_choice_for_part = (RelativeLayout) mConvertView.findViewById(R.id.rl_choice_for_part);
        rl_choice_for_time = (RelativeLayout) mConvertView.findViewById(R.id.rl_choice_for_time);
        rl_choice_for_sign = (RelativeLayout) mConvertView.findViewById(R.id.rl_choice_for_sign);

        tv_part_name = (TextView) mConvertView.findViewById(R.id.tv_part_name);
        tv_time = (TextView) mConvertView.findViewById(R.id.tv_time);
        tv_order = (TextView) mConvertView.findViewById(R.id.tv_order);
        mLoadingCover = (com.gz.logistics.widget.LoadingCover) mConvertView.findViewById(R.id.layout_loading_cover);

        mLoadingData = new Dialog(getActivity(),R.style.DialogTheme);
        mLoadingData.setContentView(R.layout.loading_data_dialog2);
        mLoadingData.setCanceledOnTouchOutside(false);
        mLoadingData.setCancelable(false);

        mFooterView = (FooterView) mInflater.inflate(R.layout.footer_view, null);
        mPullListY.getRefreshableView().addFooterView(mFooterView);
        mPullListY.setOnScrollListener(mFooterView);
        mCalendar = Calendar.getInstance();
        timeDialog = new DoubleDatePickerDialog(this.getActivity(),0,this,
                mCalendar.get(Calendar.YEAR),mCalendar.get(Calendar.MONTH),mCalendar.get(Calendar.DATE),true);
        statusList = new ArrayList<CustomerSpinnerObject>();
        OrderStatusInfo statusInfo ;
        for(int i = 1 ; i <= 2 ;i++){
            statusInfo = new OrderStatusInfo();
           if (i == 1 ){
                statusInfo.setStatus_id(Define.ORDER_STATUS_LOGISTIC_SIGNED);
                statusInfo.setStatus_name("已签收");
            }else if (i == 2 ){
                statusInfo.setStatus_id(Define.ORDER_STATUS_LOGISTIC_NOT_SIGN);
                statusInfo.setStatus_name("待签收");
                statusInfo.setIsSelected(true);
                status = 2;

            }
            statusList.add(statusInfo);
        }
        date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        endTime = format.format(new Date(date.getTime()))+" 23:59:59";//系统当前的时间
        startTime = format.format(new Date(date.getTime()))+" 00:00:00";//当天凌晨

        mPullListW.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent();
                intent.setClass(mContext, OutingAssembleDetailActivity.class);
                intent.putExtra("storage_out_id", mDataListW.get(position - 1).getStorehouse_id());
                intent.putExtra("begin_at", startTime);
                intent.putExtra("end_at",endTime);
                intent.putExtra("status",status);
                startActivityForResult(intent,109);
            }
        });
        mPullListY.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent();
                intent.setClass(mContext, OutingAssembleDetailActivity.class);
                intent.putExtra("storage_out_id", mDataListY.get(position - 1).getStorehouse_id());
                intent.putExtra("begin_at", mDataListY.get(position - 1).getSign_at());
                intent.putExtra("end_at",endTime);
                intent.putExtra("status",status);
                startActivity(intent);
            }
        });



    }

    private void initListener() {
        mySignAllOrdersOfTheAssembleListener = new MySignAllOrdersOfTheAssembleListener(this);
        mPullListY.setOnRefreshListener(this);
        mFooterView.setOnFooterViewRefreshListener(this);
        mLoadingCover.setOnLoadingCoverRefreshListener(this);
        myGetStoreHousesListener = new MyGetStoreHouseListener(this);
        outingListenerW = new OutingListenerW(this);
        rl_choice_for_part.setOnClickListener(this);//仓库点击事件
        rl_choice_for_time.setOnClickListener(this);//时间点击事件
        rl_choice_for_sign.setOnClickListener(this);//订单状态点击事件
    }


    @Override
    public void onSpinnerItemClick(int position) {
        if (position < 0){
            return;
        }
        for (int i = 0 ; i < storehouse.size() ; i++){
            if (i == position){
                storehouse.get(i).setIsSelected(true);
            }else{
                storehouse.get(i).setIsSelected(false);
            }

        }
        mPartSpinnerPopWindow.notifyDataSetChanged();
        mLoadingData.show();
        storehoust_id = ((StoreHouse)storehouse.get(position)).getStore_houseid();
        if (status == 1){
            loadDataFromServer(buildListener(RequestCode.PULL));
        }else{
            loadbuildingData();
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.rl_choice_for_part:
                if(storehouse.size() <= 0 ){
                    ToastUtils.showToast(getActivity(),"仓库列表为空");
                    return ;
                }
                mPartSpinnerPopWindow.setWidth(rl_choice_for_part.getWidth()*2);
                mPartSpinnerPopWindow.showAsDropDown(rl_choice_for_part);
                break;
            case R.id.rl_choice_for_time:
                timeDialog.show();
                break;
            case R.id.rl_choice_for_sign://订单状态点击事件
                if (statusList.size() <= 0){
                    ToastUtils.showToast(getActivity(),"订单列表为空");
                    return;
                }
                mStatusSpinnerPopWindow.setWidth(rl_choice_for_sign.getWidth());
                mStatusSpinnerPopWindow.showAsDropDown(rl_choice_for_sign);
                break;
        }
    }
    /**
     *  弹出时间选择 Dialog，并选择对应开始和介素时间后，点击确定按钮，将会触发以下方法
     *
     */
    @Override
    public void onDateSet(DatePicker startDatePicker, int startYear, int startMonthOfYear, int startDayOfMonth, DatePicker endDatePicker, int endYear, int endMonthOfYear, int endDayOfMonth) {
        startTime = String.format("%d-%d-%d",startYear,startMonthOfYear+1,startDayOfMonth)+" 00:00:00";
        endTime = String.format("%d-%d-%d",endYear,endMonthOfYear+1,endDayOfMonth)+" 23:59:59";
        CrashHandler.i(TAG, "开始时间=" + startTime + "结束时间=" + endTime);
        mLoadingData.show();
        if (status == 1){
            loadDataFromServer(buildListener(RequestCode.PULL));
        }else{
            loadbuildingData();
        }

    }

    @Override
    public void onFooterViewRefresh() {
        loadDataFromServer(buildListener(RequestCode.SCROLL));
    }


    @Override
    public void onLoadingCoverRefresh() {
        if (status == 1){
            loadDataFromServer(buildListener(RequestCode.PULL));
        }else
        {
            loadbuildingData();
        }

    }

    @Override
    public void onRefresh(PullToRefreshBase refreshView) {
        loadDataFromServer(buildListener(RequestCode.PULL));
    }

    /**
     * 回调函数
     * @param arg0
     * @param resultcode
     * @param intent
     */
    @Override
    public void onActivityResult(int arg0, int resultcode, Intent intent) {
        switch (resultcode) {
            case 109:
                loadbuildingData();
                break;
            default:
                break;
        }
    }

    private void loadDataFromServer(GetWillOutOfStorageAssemblesListenerY getMaintenaceListListener) {
        mPullListY.setVisibility(View.VISIBLE);
        mFooterView.setVisibility(View.VISIBLE);
        mPullListW.setVisibility(View.GONE);
        if(getMaintenaceListListener.getRequestCode() == RequestCode.PULL) {
            page = 1;
        }else if(getMaintenaceListListener.getRequestCode() == RequestCode.SCROLL) {
            page++;
        }
        IOrder.getInstance().getWillOutStorageAssemblesY(storehoust_id, startTime, endTime, status, page, getMaintenaceListListener);

    }
    /**
     * 预出库单列表 数据获取回调接口
     */
    private GetWillOutOfStorageAssemblesListenerY buildListener(RequestCode requestCode) {
        return new GetWillOutOfStorageAssemblesListenerY(requestCode) {
            @Override
            public void onResponseFailed() {
                // TODO Auto-generated method stub
                mLoadingCover.onRefreshFailed();
                mFooterView.onRefreshFailed();
                if (mPullListY.isRefreshing()) {
                    mPullListY.getLoadingLayoutProxy().refreshFailed();
                }
                if(mLoadingData.isShowing()){
                    mLoadingData.dismiss();
                }
            }

            @Override
            public void onOffline() {
                // TODO Auto-generated method stub
                mLoadingCover.onRefreshFailed(Define.MSG_OFFLINE_ERROR);
                if (mPullListY.isRefreshing()) {
                    mPullListY.getLoadingLayoutProxy().refreshFailed();
                }
                if(mLoadingData.isShowing()){
                    mLoadingData.dismiss();
                }
            }

            @Override
            public void onNoNetWork() {
                // TODO Auto-generated method stub
                if (mPullListY.isRefreshing()) {
                    mPullListY.getLoadingLayoutProxy().refreshFailed();
                }
                if(mLoadingData.isShowing()){
                    mLoadingData.dismiss();
                }
                mFooterView.onRefreshFailed();
                mLoadingCover.onRefreshFailed(Define.MSG_NO_NETWORK);
            }

            @Override
            public void onNoMoreData() {
                // TODO Auto-generated method stub
                if (mPullListY.isRefreshing()) {
                    mPullListY.getLoadingLayoutProxy().refreshSuccess();
                }
                if(mLoadingData.isShowing()){
                    mLoadingData.dismiss();
                }
                mFooterView.onRefreshComplete();
                mLoadingCover.onRefreshFailed("没有已签收的商品信息");

            }

            @Override
            public void onNoConditionAssembles() {
                mLoadingCover.onRefreshFailed("没有信息记录");
                if(mLoadingData.isShowing()){
                    mLoadingData.dismiss();
                }
            }

            @Override
            public void onResponseSuccess(List<WillOutStorageAassembleY> lists) {

                if (this.requestCode == RequestCode.PULL) {
                    mDataListY.clear();
                }
                mDataListY.addAll(lists);
                assembleAdapterY.notifyDataSetChanged();
                if (lists.size() < Define.LISTVIEW_ITEM_MIN_SIZE) {
                    mFooterView.onRefreshComplete();
                    mPullListY.setOnScrollListener(null);
                } else {
                    assembleAdapterY.notifyDataSetChanged();
                    mFooterView.onRefreshSuccess();//刷新成功并且后面还有数据可以进行加载
                    mPullListY.setOnScrollListener(mFooterView);
                }
                if (mPullListY.isRefreshing()) {
                    mPullListY.getLoadingLayoutProxy().refreshSuccess();
                }
                if(mLoadingData.isShowing()){
                    mLoadingData.dismiss();
                }
                mLoadingCover.onRefreshSuccess();
            }
        };
    }



    /**
     * 获取仓库的监听器
     */
    public static  class MyGetStoreHouseListener extends GetStoreHouseListener{
        private OutingFragment mOuter;

        public MyGetStoreHouseListener(OutingFragment mOuter) {
            this.mOuter = mOuter;
        }

        public void release(){
            new WeakReference<OutingFragment>(mOuter);
        }

        @Override
        public void onResponseSuccess(List<StoreHouse> storeHouses) {
            StoreHouse storeinfo = new StoreHouse();
            storeinfo.setStore_houseid(0);
            storeinfo.setIsSelected(true);
            storeinfo.setStore_housename("全部");
            storeHouses.add(0, storeinfo);

            mOuter.storehouse.clear();
            mOuter.storehouse.addAll(storeHouses);
            mOuter.mHandler.sendEmptyMessage(2);


        }
        @Override
        public void onNoMoreData() {

        }
        @Override
        public void onResponseFailed() {

        }
    }




    public static class MyHandler extends android.os.Handler{
        private OutingFragment mOuter;

        public MyHandler(OutingFragment mOuter) {
            this.mOuter = mOuter;
        }
        public void release(){
            new WeakReference<OutingFragment>(mOuter);
        }

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case 1:
                    IOrder.getInstance().getStoreHouse(Integer.toString(mOuter.userInfo.getUser_id()), mOuter.myGetStoreHousesListener);
                    break;
                case 2:
                    mOuter.mPartSpinnerPopWindow.notifyDataSetChanged();
                    break;
            }
        }
    }


    /**
     * 状态
     */
    public static class MyStatusSpinnerItemSelectListener implements SpinerPopWindow.ISpinnerOnItemSelectListener {
        private OutingFragment mOuter;

        public MyStatusSpinnerItemSelectListener(OutingFragment mOuter) {
            this.mOuter = mOuter;
        }

        public void release(){
            new WeakReference<OutingFragment>(mOuter);
        }
        @Override
        public void onSpinnerItemClick(int position) {
            mOuter.mLoadingData.show();
            mOuter.page = 1;
            mOuter.status = ((OrderStatusInfo)mOuter.statusList.get(position)).getStatus_id();

            for(int j = 0 ; j < mOuter.statusList.size() ; j++){ // 把选中的状态置为选中状态，
                if(j == position){
                    (mOuter.statusList.get(j)).setIsSelected(true);
                }else{
                    (mOuter.statusList.get(j)).setIsSelected(false);
                }
            }
            if (mOuter.status == 1){
                mOuter.loadDataFromServer(mOuter.buildListener(RequestCode.PULL));
            }else{
                mOuter.loadbuildingData();
            }



        }
    }

    /**
     * 获取未签收仓库列表监听（不分页）
     */
    private static class OutingListenerW extends GetWillOutOfStorageAssemblesListener{
        private OutingFragment mOuter;
        public OutingListenerW(OutingFragment outer){
            this.mOuter = outer;
        }
        public void release(){
            new WeakReference<OutingFragment>(mOuter);
        }

        @Override
        public void onNoConditionAssembles() {
            mOuter.mLoadingCover.onRefreshFailed("没有记录");

        }

        @Override
        public void onResponseSuccess(List<WillOutStorageAassemble> lists) {
            if(mOuter == null){
                return;
            }
            mOuter.mDataListW.clear();
            mOuter.mDataListW.addAll(lists);
            mOuter.assembleAdapter.notifyDataSetChanged();
            mOuter.mLoadingCover.onRefreshSuccess();
            if (mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
        }

        @Override
        public void onNoMoreData() {
            if(mOuter == null){
                return;
            }
            mOuter.mLoadingCover.setVisibility(View.VISIBLE);
            mOuter.mLoadingCover.onRefreshFailed("暂无信息");
            if (mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }

        }

        @Override
        public void onNoNetWork() {
            if(mOuter == null){
                return;
            }
            if (mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
            mOuter.mLoadingCover.onRefreshFailed();
            ToastUtils.showToast(mOuter.getActivity(), Define.MSG_NO_NETWORK);
        }

        @Override
        public void onResponseFailed() {
            if(mOuter == null){
                return;
            }
            mOuter.mLoadingCover.onRefreshFailed();
            if (mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
        }

    }
    /**
     * 点击签收其下所有订单，触发该方法
     * @param pre_out_number
     */
    @Override
    public void signAll(int pre_out_number,String begin_at,String end_at) {
        mLoadingData.show();
        IOrder.getInstance().signAllOrdersOfThisAssemble(pre_out_number,begin_at,end_at, mySignAllOrdersOfTheAssembleListener);

}
    /**
     * 签收其下所有订单 监听器
     */
    private static  class  MySignAllOrdersOfTheAssembleListener extends SignAllOrdersOfTheAssembleListener {
        private OutingFragment mOuter;

        public MySignAllOrdersOfTheAssembleListener(OutingFragment mOuter) {
            this.mOuter = mOuter;
        }
        public void release(){
            new WeakReference<OutingFragment>(mOuter);
        }

        @Override
        public void onPartOrdersSignFail() {
            if(mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
            ToastUtils.showToast(mOuter.mContext, "签收其下所有订单物流签收部分失败");

        }

        @Override
        public void onNoSignableOrderInThisAssemble() {
            if(mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
            ToastUtils.showToast(mOuter.mContext, "整体确认物流签收全部失败");
        }

        @Override
        public void onThisAssembleIsDiscarder() {
            if(mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
            ToastUtils.showToast(mOuter.mContext, "未签收起始时间不能为空");
        }

        @Override
        public void onResponseSuccess() {
            if(mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
            ToastUtils.showToast(mOuter.mContext, "签收成功");
            mOuter.assembleAdapter.notifyDataSetChanged();
            mOuter.loadbuildingData();

        }

        @Override
        public void onNoNetWork() {
            if(mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
            ToastUtils.showToast(mOuter.mContext, Define.MSG_NO_NETWORK);
        }

        @Override
        public void onOffline() {
            if(mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
            ToastUtils.showToast(mOuter.mContext, Define.MSG_OFFLINE_ERROR);
        }

        @Override
        public void onResponseFailed() {
            if(mOuter.mLoadingData.isShowing()){
                mOuter.mLoadingData.dismiss();
            }
            ToastUtils.showToast(mOuter.mContext,"请求失败");

        }
    }


}
